const multer = require('multer');

const fileFilter = function (req, file, callback) {
    console.log(file);
    //检测文件后缀名，符合图片格式允许上传
    if (/[.](jpg|jpeg|png|gif)$/.test(file.originalname)) {
        return callback(null, true);
    }
    callback(new Error('wrong type:)'), false);
};

module.exports = multer({
    dest: 'uploads/images/',
    fileFilter
});